package com.fh.modules.ums.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fh.common.api.vo.Result;
import com.fh.common.aspect.annotation.AutoLog;
import com.fh.common.constant.CommonConstant;
import com.fh.common.query.QueryWrapperUtil;
import com.fh.modules.ums.entity.UmsIntegrationChange;
import com.fh.modules.ums.service.IUmsIntegrationChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: Controller
 * @Description: 用户积分控制器
 * @author： fuhao
 * @date：   2019-10-12
 * @version： V1.0
 */
@RestController
@Slf4j
@Api("用户积分信息")
public class UmsIntegrationChangeController {
    @Autowired
    private IUmsIntegrationChangeService umsIntegrationChangeService;

    /**
     * 分页列表查询
     * @param umsIntegrationChange
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/ums/umsIntegrationChang/list")
    @ApiOperation("分页列表查询")
    @AutoLog(value="积分信息分页查询",logType= CommonConstant.LOG_TYPE_QUERY)
    public Result queryPageList(UmsIntegrationChange umsIntegrationChange,
                                @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        QueryWrapper<UmsIntegrationChange> queryWrapper = new QueryWrapper<>();
        umsIntegrationChange.setDelFlag(CommonConstant.DEL_FLAG_0);
        QueryWrapperUtil.initQueryWrapper(queryWrapper, umsIntegrationChange);
        Page<UmsIntegrationChange> page = new Page<>(pageNo, pageSize);
        IPage<UmsIntegrationChange> pageList = umsIntegrationChangeService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 用户积分列表查询
     * @param memeberId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/ums/umsIntegrationChang/usersList")
    @ApiOperation("用户积分列表查询")
    @AutoLog(value="用户积分列表查询",logType= CommonConstant.LOG_TYPE_QUERY)
    public Result queryUsers(String memeberId,
                                @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        QueryWrapper<UmsIntegrationChange> queryWrapper = new QueryWrapper<>();
        UmsIntegrationChange umsIntegrationChange=new UmsIntegrationChange();
        umsIntegrationChange.setMemberId(memeberId);
        umsIntegrationChange.setDelFlag(CommonConstant.DEL_FLAG_0);
        QueryWrapperUtil.initQueryWrapper(queryWrapper, umsIntegrationChange);
        Page<UmsIntegrationChange> page = new Page<>(pageNo, pageSize);
        IPage<UmsIntegrationChange> pageList = umsIntegrationChangeService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

}
